package com.guigu.dealservice.controller;


import com.guigu.common.utils.R;
import com.guigu.dealservice.service.TotalService;
import com.guigu.dealservice.vo.TotalVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/dealservice/total")
public class TotalController {
    @Autowired
    private TotalService totalService;
    @PostMapping("/queryTotalList/{pageNum}/{pageSize}")
    public R queryTotalList(@PathVariable("pageNum") Integer pageNum,
                            @PathVariable("pageSize") Integer pageSize,
                            @RequestBody TotalVo vo)
        {
            // 确保saleTime数组有效
            if (vo.getSaleTime() != null && vo.getSaleTime().size() < 2) {
                // 如果数组长度不足2，设置为null避免后续错误
                vo.setSaleTime(null);
            }
        return totalService.queryTotalList(vo, pageNum, pageSize);
    }

    @GetMapping("/querySalesByMonthAndSalesman/{months}")
    public R querySalesByMonthAndSalesman(@PathVariable("months") Integer months) {
        if (months == null)
            months=6;
        return totalService.querySalesByMonthAndSalesman(months);
    }

    //传：业务员ID和月份
    @GetMapping("/querySalesByMonthAndSalesman2/{eid}/{months}")
    public R querySalesByMonthAndSalesman2(@PathVariable Integer eid,@PathVariable("months") Integer months) {
        if (months == null)
            months=6;
        return totalService.querySalesByMonthAndSalesman2(eid,months);
    }
}
